home *** CD-ROM | disk | FTP | other *** search
- Path: peer-news.britain.eu.net!psinntp!psinntp!psinntp!pipeline!not-for-mail
- From: gordo@nyc.pipeline.com (Gordon Krefting)
- Newsgroups: comp.lang.c++
- Subject: Re: When to use "->" vs "." when calling Member functions
- Date: 17 Jan 1996 10:15:23 -0500
- Organization: The Pipeline
- Message-ID: <4dj3qb$4kn@pipe3.nyc.pipeline.com>
- References: <4dhea1$6v8@ornews.intel.com>
- NNTP-Posting-Host: pipe3.nyc.pipeline.com
- X-PipeUser: gordo
- X-PipeHub: nyc.pipeline.com
- X-PipeGCOS: (Gordon Krefting)
- X-Newsreader: The Pipeline v3.4.0
-
- On Jan 17, 1996 00:00:59 in article <When to use "->" vs "." when calling
- Member functions>, 'thurman_b_miller@ccm2.hf.intel.com (Thurman Miller)'
- wrote:
-
-
- >I'm confused, so please no harsh remarks :)
- >
- >If I've got:
- >
- >class Cfoo
- >{
- > something * getptr();
- > somethingelse* m_other;
- >}
- >
- >something * foo::getptr()
- >{
- > return m_other;
- >}
- >
- >
- >Now...if I'm in another class....
- >
- > Cfoo foo;
- > somethingelse* = foo.getptr();
- >
- >why doesn't the following work?
- >
- > somethingelse* = foo->getptr();
- >
- >I get compile error about no "->" overloaded operator....
- >
- >Can someone point out the obvious when I use one notation over
- >another?
- >
- >TIA
- >
- >Thurman
-
- Use "->" to access elements of an object when you have a pointer to the
- object. Use "." when you have the object itself:
-
- ...
- CFoo foo;
- CFoo * pfoo;
-
- ...
- foo.member = 1;
- pfoo->member = 1;
-
- HTH
- gordo
-